package com.partner.frame;

import java.util.*;
import javax.servlet.http.*;

public class SessionTimoutListener implements HttpSessionListener
{

   public void sessionCreated(HttpSessionEvent sessionEvent)
   {
      StringBuffer strbufOut = null;
      HttpSession httpSession = null;
      Enumeration<String> enumAttr = null;
      String attrName = "", attrValue = "";
      
      strbufOut = new StringBuffer();
      httpSession = sessionEvent.getSession();
      
      strbufOut.append("------sessionCreated - sessionId[" + httpSession.getId() + "]------\n");
      enumAttr = httpSession.getAttributeNames();
      while(enumAttr.hasMoreElements())
      {
         attrName = enumAttr.nextElement();
         attrValue = httpSession.getAttribute("attrName") == null ? "NULL" : httpSession.getAttribute("attrName").toString();
         strbufOut.append("Name[" + attrName + "] Value[" + attrValue + "]\n");
      }
      strbufOut.append("------sessionCreated - sessionId[" + httpSession.getId() + "]------\n");
      
      return ;
   }

   public void sessionDestroyed(HttpSessionEvent sessionEvent)
   {
      StringBuffer strbufOut = null;
      HttpSession httpSession = null;
      Enumeration<String> enumAttr = null;
      String attrName = "", attrValue = "";
      
      strbufOut = new StringBuffer();
      httpSession = sessionEvent.getSession();
      
      strbufOut.append("------sessionDestroyed - sessionId[" + httpSession.getId() + "]------\n");
      enumAttr = httpSession.getAttributeNames();
      while(enumAttr.hasMoreElements())
      {
         attrName = enumAttr.nextElement();
         attrValue = httpSession.getAttribute(attrName) == null ? "NULL" : httpSession.getAttribute(attrName).toString();
         strbufOut.append("Name[" + attrName + "] Value[" + attrValue + "]\n");
      }
      strbufOut.append("------sessionDestroyed - sessionId[" + httpSession.getId() + "]------\n");
      //System.out.println(strbufOut.toString());
      
      return ;
   }

}
